import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Home from '@/pages/Home'
import Cart from '@/pages/Cart'
import Category from '@/pages/Category'
import User from '@/pages/User'
import ProductList from '@/components/ProductList'

Vue.use(VueRouter)

const routes = [
  {
    path: '/user',
    component: User
  },
  {
    path: '/cart',
    component: Cart
  },
  {
    path: '/category',
    component: Category,
    children: [
      {
        path: '/categoryItem/:categoryId',
        name: 'ProductList',
        component: ProductList
      }
    ]
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
